// pages/order/order.js

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:"",
    popup:true,
    show: true,
    phone:"",
search:"",

    order:[
      {
        orderid:"1",
        price:"16",
        // shop:"饱了吗",
        customer:"欧军",
        service:"已送达",
        goods:[
             {
               goodsname:"烤奶",
               url:"https://img.yzcdn.cn/vant/cat.jpeg"
             },
             {
              goodsname:"烤奶",
              url:"https://img.yzcdn.cn/vant/cat.jpeg"
            },
        ]
      },
      {
        orderid:"2",
        price:"16",
        shop:"饱了吗",
        service:"已送达",
        goods:[
          {
            goodsname:"烤奶",
            url:"https://img.yzcdn.cn/vant/cat.jpeg"
          },
          {
           goodsname:"烤奶",
           url:"https://img.yzcdn.cn/vant/cat.jpeg"
         },
        ]
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.dialog = this.selectComponent("#dialog");
    this.popup = this.selectComponent("#popup");
    let that = this
    this.setData({
      phone:wx.getStorageSync('phone'),
    })
    if (that.data.phone=="") {
      that.dialog.showdialog();
    } else {
    this.setData({
      phone : wx.getStorageSync('phone'),
    })
    wx.request({
      url: '',
      method:"POST",
      header:{
        "cookie":wx.getStorageSync('sessionid'),
        "cookie":wx.getStorageSync('session'),
      }, 
     data:{
       phone:options.phone ,
     },
     success (res) {
      console.log(res)
      that.data.status=res.data.status
    }
    })
  }
  },
  _success() {
    this.dialog.hidedialog();
    wx.switchTab({
      url:"/pages/index/index",
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
round:function(e){
  this.setData({
    search: e.detail,
  });
  console.log(this.data.search)
  // Toast('搜索' + this.data.value);
 
},
onClick:function(){
  let that = this
  wx.request({
    url: '',
    method:"POST",
    header:{
      "cookie":wx.getStorageSync('sessionid'),
    }, 
   data:{
     phone:that.data.phone,
     search:that.data.search,

   },

   success (res) {
    console.log(res)
    that.data.status=res.data.status
  }
  })
},
cell :function(e) {
  console.log(e.currentTarget.id)
  // wx.request({
  //   url: '',
  //   method:"POST",
  //   header:{
  //     "cookie":wx.getStorageSync('sessionid'),
  //   }, 
  //  data:{
  //    phone:that.data.phone,
  //    orderid:e.currentTarget.id,
  //  },

  //  success (res) {

 
  // }

  // })
  wx.navigateTo({
    url:"/pages/order/orderdetails/orderdetails?orderid="+[e.currentTarget.id]
  })
},
delete:function(e){
console.log(e.target.id)
  this.popup.showPopup();
this.setData({
  id:e.target.id
})
},
//取消删除
merchant() {
  this.popup.hidePopup();
},
//删除
customer() {
  let that = this
 
  this.popup.hidePopup();
  wx.request({
    url: '',
    method:"POST",
   data:{
     phone:that.data.phone,
     id:that.data.id,
    delete:"delete",
   },
   success (res) {

  }
  })

},
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})